# Contributor: Alex Denes <caskd@redxen.eu>
# Maintainer: Alex Denes <caskd@redxen.eu>
pkgname=prometheus-ipmi-exporter
_pkgname=ipmi_exporter
pkgver=1.8.0
pkgrel=0
pkgdesc="Remote IPMI exporter for Prometheus"
url="https://github.com/prometheus-community/ipmi_exporter"
# ppc64le - from freeipmi
arch="all !ppc64le"
license="MIT"
depends="freeipmi"
makedepends="go>=1.19 promu"
options="net"
subpackages="$pkgname-openrc $pkgname-doc"
install="$pkgname.pre-install $pkgname.pre-upgrade"
source="$_pkgname-$pkgver.tar.gz::https://github.com/prometheus-community/$_pkgname/archive/v$pkgver.tar.gz
	ipmi-exporter.initd
	ipmi-exporter.confd
	0001-disable-go-race-detector.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"

export GOFLAGS="$GOFLAGS -modcacherw"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make PROMU=/usr/bin/promu build
}

check() {
	make test
}

package() {
	install -Dm755 ipmi_exporter-"$pkgver" "$pkgdir"/usr/bin/ipmi_exporter

	install -Dm755 "$srcdir"/ipmi-exporter.initd "$pkgdir"/etc/init.d/ipmi-exporter
	install -Dm644 "$srcdir"/ipmi-exporter.confd "$pkgdir"/etc/conf.d/ipmi-exporter

	for f in configuration.md metrics.md; do
		install -Dm644 docs/"$f" "$pkgdir"/usr/share/doc/"$pkgname"/"$f"
	done
}
sha512sums="
1a42f5478297803a1de5f2062cf73f49d60ba1877bb13387233362608fa1b53e2cc88d0acae18ff209df173bf2399a1dbc64ce1f45f7502942dad67c55ad09d9  ipmi_exporter-1.8.0.tar.gz
76825471605ff20210fb60d4cc6e96f2894702ed5583e0a499e881af2e1ad7ee322fe8afdd2078865ea3f2ff349091b8bc11735c4e3f9bc2c88a8230c2f4c180  ipmi-exporter.initd
64f9f9f07d8ddab625c5776794df1b5b02882015afedf6b096b0cfef27c22cf4468192333b5a98aaaf6cb1261904a26bc84402efd11bb80e07a7be30a44525a7  ipmi-exporter.confd
f9ef10d85ebd57a19d44db08a62835c32aa8e0ec7a1ac1829c7fd4a73de66ad765782405cd1d2a9cb7277052d5a5941439b8eab0ec2023fcab7e40bafbfe6a75  0001-disable-go-race-detector.patch
"
